# -*- coding: utf-8 -*-
# @Time     : 2021/11/26 15:33
# @Author   : wljess
# @File     : 性能测试.py
# @Describe : 
# @Software : PyCharm

import time
import random

def decorator(func):
    def inner(*args, **kwargs):
        print("装饰器性能测试...")
        s_time = time.perf_counter()
        res = func(*args, **kwargs)
        e_time = time.perf_counter()
        print(f"程序运行时间：{e_time - s_time}s")
        return res
    return inner

@decorator
def loop(num):
    s = 0
    for i in range(num):
        random_num = random.randint(0, 10000000)
        #print(f"循环第{i}次得到的随机数：{random_num}")
        s += random_num
    return s

if __name__ == '__main__':
    print(loop(100))
    print("=" * 50)
    print(loop(1000))
    print("=" * 50)
    print(loop(10000))
    print("=" * 50)
    print(loop(100000))
    print("=" * 50)
    print(loop(10000000))
    print("=" * 50)
    print(loop(100000000))
